import styled, { keyframes } from 'styled-components';

// 动画定义
const pulseAnimation = keyframes`
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
`;

const glowAnimation = keyframes`
  0%, 100% {
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
  }
  50% {
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.8), 0 0 30px rgba(0, 255, 255, 0.6);
  }
`;

const slideIn = keyframes`
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
`;

export const CenterPage = styled.div`
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
`;

export const CenterTopBox = styled.div`
  flex: 0 0 35%;
  position: relative;
  background: linear-gradient(135deg, 
    rgba(0, 102, 255, 0.08) 0%, 
    rgba(0, 204, 255, 0.05) 100%);
  border: 1px solid rgba(0, 153, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  overflow: hidden;
  
  /* 容器内部边框发光效果 */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    padding: 1px;
    background: linear-gradient(135deg, 
      rgba(0, 255, 255, 0.4) 0%, 
      rgba(0, 153, 255, 0.2) 50%, 
      rgba(0, 255, 255, 0.4) 100%);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    z-index: -1;
  }

  .center-top-borderBox {
    width: 100%;
    height: 100%;
  }

  .center-top {
    padding: 0.03rem; /* 极大减少内边距 */
    height: 100%;
    display: flex;
    flex-direction: column;

    .title-dis {
      display: flex;
      justify-content: space-between;
      margin: 0.02rem 0; /* 减少标题边距 */
      font-size: 0.18rem; /* 大幅增加标题字体 */
      color: rgba(255, 255, 255, 0.9);
      font-weight: bold;

      .title-dis-keyword {
        color: #00ffff;
        font-weight: bold;
        text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
        margin-left: 0.08rem;
      }
    }

    /* 图表容器 */
    > div:last-child {
      flex: 1;
      min-height: 0;
    }
  }

  /* 悬停效果 */
  &:hover {
    border-color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    transform: translateY(-2px);
    transition: all 0.3s ease;
  }
`;

export const CenterBottomBox = styled.div`
  flex: 1;
  position: relative;
  background: linear-gradient(135deg, 
    rgba(0, 102, 255, 0.08) 0%, 
    rgba(0, 204, 255, 0.05) 100%);
  border: 1px solid rgba(0, 153, 255, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  overflow: hidden;
  
  /* 容器内部边框发光效果 */
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    padding: 1px;
    background: linear-gradient(135deg, 
      rgba(0, 255, 255, 0.4) 0%, 
      rgba(0, 153, 255, 0.2) 50%, 
      rgba(0, 255, 255, 0.4) 100%);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    z-index: -1;
  }

  .center-bottom-borderBox {
    width: 100%;
    height: 100%;
  }

  .center-bottom {
    padding: 0.03rem; /* 极大减少内边距 */
    height: 100%;
    display: flex;
    flex-direction: column;

    .title-dis {
      display: flex;
      justify-content: space-between;
      margin: 0.02rem 0; /* 减少标题边距 */
      font-size: 0.18rem; /* 大幅增加标题字体 */
      color: rgba(255, 255, 255, 0.9);
      font-weight: bold;

      .title-dis-keyword {
        color: #00ffff;
        font-weight: bold;
        text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
        margin-left: 0.08rem;
      }
    }

    /* 图表容器 */
    > div:last-child {
      flex: 1;
      min-height: 0;
    }
  }

  /* 悬停效果 */
  &:hover {
    border-color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    transform: translateY(-2px);
    transition: all 0.3s ease;
  }
`;

export const CenterContent = styled.div`
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  padding: 0.2rem;
  
  .chart-container {
    width: 100%;
    flex: 1;
    margin-top: 0.1rem;
  }
  
  .decoration-top {
    width: 90%;
    height: 0.3rem;
    margin-bottom: 0.5rem;
    
    .decoration5 {
      width: 100%;
      height: 100%;
    }
  }
  
  .decoration-bottom {
    width: 90%;
    height: 0.3rem;
    margin-top: 0.5rem;
    
    .decoration12 {
      width: 100%;
      height: 100%;
    }
  }
`;

export const StatsCenter = styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  
  .main-stats {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 5.5rem;
    gap: 0.4rem;
    
    .stats-row {
      display: flex;
      gap: 0.4rem;
      
      &.top-row {
        .stat-item {
          flex: 1;
          height: 1.8rem;
          
          .stat-value {
            font-size: 0.8rem;
          }
        }
      }
      
      &.bottom-row {
        .stat-item {
          flex: 1;
          height: 1.3rem;
          
          .stat-value {
            font-size: 0.55rem;
          }
        }
      }
    }
    
    .stat-item {
      text-align: center;
      background: linear-gradient(135deg, rgba(0, 102, 255, 0.1) 0%, rgba(0, 204, 255, 0.1) 100%);
      border: 1px solid rgba(0, 153, 255, 0.4);
      border-radius: 0.15rem;
      padding: 0.25rem;
      backdrop-filter: blur(10px);
      transition: all 0.3s ease;
      animation: ${slideIn} 1s ease-out;
      display: flex;
      flex-direction: column;
      justify-content: center;
      
      &:hover {
        border-color: rgba(0, 255, 255, 0.8);
        box-shadow: 0 0.15rem 0.4rem rgba(0, 255, 255, 0.2);
        transform: translateY(-0.03rem);
      }
      
      .stat-value {
        font-weight: bold;
        color: #00ffff;
        animation: ${glowAnimation} 2s ease-in-out infinite;
        line-height: 1;
        margin-bottom: 0.15rem;
      }
      
      .stat-label {
        font-size: 0.16rem;
        color: rgba(255, 255, 255, 0.8);
        font-weight: 400;
      }
    }
  }
`;

export const DataStream = styled.div`
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 153, 255, 0.3);
  border-radius: 10px;
  padding: 0.3rem;
  min-width: 3rem;
  backdrop-filter: blur(5px);
  
  .stream-title {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.2rem;
    
    span {
      font-size: 0.15rem;
      color: #00d4ff;
      font-weight: bold;
      margin-right: 0.1rem;
    }
    
    .pulse-dot {
      width: 0.1rem;
      height: 0.1rem;
      background: #00ff00;
      border-radius: 50%;
      animation: ${pulseAnimation} 1.5s ease-in-out infinite;
      box-shadow: 0 0 8px #00ff00;
    }
  }
  
  .stream-items {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
  }
  
  .stream-item {
    text-align: center;
    padding: 0.1rem;
    
    .stream-label {
      font-size: 0.08rem;
      color: rgba(255, 255, 255, 0.7);
      margin-bottom: 0.05rem;
    }
    
    .stream-value {
      font-size: 0.12rem;
      color: #ffffff;
      font-weight: bold;
      margin-bottom: 0.05rem;
    }
    
    .stream-trend {
      font-size: 0.08rem;
      font-weight: bold;
      
      &.positive {
        color: #00ff88;
      }
      
      &.negative {
        color: #ff6b6b;
      }
    }
  }
`;

export const CenterBottom = styled.div`
  display: flex;
  margin-bottom: 0.25rem;
  margin-top: 0.875rem;
  width: 100%;
  height: 3.25rem;
  .detail-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: space-between;
    justify-content: space-around;
    width: 100%;
    &-item {
      display: flex;
      align-items: center;
      position: relative;
      height: 1.5625rem;
      padding: 0 0.125rem;
      width: 32%;
      border-radius: 5px;
      border: 1px solid #343f4b;
      background-color: rgba(19, 25, 47, 0.8);
      img {
        width: 1.25rem;
        height: 1.25rem;
      }
      .detail-item-text {
        margin-left: 0.125rem;
        h3 {
          color: #bcdcff;
          font-size: 16px;
          margin-bottom: 0.25rem;
        }
        span {
          font-weight: 500px;
          font-size: 0.25rem;
          font-weight: bolder;
          background: linear-gradient(to bottom, #fff, #4db6e5);
          color: transparent;
          -webkit-background-clip: text;
          background-clip: text;
        }
        .unit {
          font-size: 0.2rem;
          margin-left: 0.125rem;
        }
      }
    }
  }
`;
